package sybel;

import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;


public class DomModelSupport {
    private ArrayList listenerList = new ArrayList();

    public void addTreeModelListener(TreeModelListener listener) {
        if (listener != null && !listenerList.contains(listener)) {
			listenerList.add(listener);
		}
    }

    public void removeTreeModelListener(TreeModelListener listener) {
        if (listener != null) {
			listenerList.remove(listener);
		}
    }

    public void fireTreeNodesChanged(TreeModelEvent e) {
        Iterator listeners = listenerList.iterator();
        while (listeners.hasNext()) {
            TreeModelListener listener = (TreeModelListener) listeners.next();
            listener.treeNodesChanged(e);
        }
    }

    public void fireTreeNodesInserted(TreeModelEvent e) {
        Iterator listeners = listenerList.iterator();
        while (listeners.hasNext()) {
            TreeModelListener listener = (TreeModelListener) listeners.next();
            listener.treeNodesInserted(e);
        }
    }

    public void fireTreeNodesRemoved(TreeModelEvent e) {
        Iterator listeners = listenerList.iterator();
        while (listeners.hasNext()) {
            TreeModelListener listener = (TreeModelListener) listeners.next();
            listener.treeNodesRemoved(e);
        }
    }

    public void fireTreeStructureChanged(TreeModelEvent e) {
        Iterator listeners = listenerList.iterator();
        while (listeners.hasNext()) {
            TreeModelListener listener = (TreeModelListener) listeners.next();
            listener.treeStructureChanged(e);
        }
    }

}
